# Copyright 1999-2025 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=8

DESCRIPTION="An AST-based pattern checker for JavaScript."
HOMEPAGE="https://eslint.org"

NODEJS_DEPS_SRC_URI="http://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.6.0.tgz -> @eslint-community@eslint-utils-4.6.0.tgz
                     http://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz -> @eslint-community@regexpp-4.12.1.tgz
                     http://registry.npmjs.org/@eslint/config-array/-/config-array-0.20.0.tgz -> @eslint@config-array-0.20.0.tgz
                     http://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.2.1.tgz -> @eslint@config-helpers-0.2.1.tgz
                     http://registry.npmjs.org/@eslint/core/-/core-0.13.0.tgz -> @eslint@core-0.13.0.tgz
                     http://registry.npmjs.org/@eslint/core/-/core-0.12.0.tgz -> @eslint@core-0.12.0.tgz
                     http://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz -> @eslint@eslintrc-3.3.1.tgz
                     http://registry.npmjs.org/@eslint/js/-/js-9.24.0.tgz -> @eslint@js-9.24.0.tgz
                     http://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz -> @eslint@object-schema-2.1.6.tgz
                     http://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.8.tgz -> @eslint@plugin-kit-0.2.8.tgz
                     http://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz -> @humanfs@core-0.19.1.tgz
                     http://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz -> @humanfs@node-0.16.6.tgz
                     http://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz -> @humanwhocodes@module-importer-1.0.1.tgz
                     http://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.2.tgz -> @humanwhocodes@retry-0.4.2.tgz
                     http://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz -> @humanwhocodes@retry-0.3.1.tgz
                     http://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz -> @types@estree-1.0.7.tgz
                     http://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz -> @types@estree-1.0.6.tgz
                     http://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz -> @types@json-schema-7.0.15.tgz
                     http://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz
                     http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz
                     http://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz
                     http://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz
                     http://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz
                     http://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz
                     http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz
                     http://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz
                     http://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz
                     http://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz
                     http://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz
                     http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz
                     http://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz
                     http://registry.npmjs.org/debug/-/debug-4.4.0.tgz
                     http://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz
                     http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz
                     http://registry.npmjs.org/eslint-scope/-/eslint-scope-8.3.0.tgz
                     http://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz
                     http://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz
                     http://registry.npmjs.org/espree/-/espree-10.3.0.tgz
                     http://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz
                     http://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz
                     http://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz
                     http://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz
                     http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz
                     http://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz
                     http://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz
                     http://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz
                     http://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz
                     http://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz
                     http://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz
                     http://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz
                     http://registry.npmjs.org/globals/-/globals-14.0.0.tgz
                     http://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz
                     http://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz
                     http://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz
                     http://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz
                     http://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz
                     http://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz
                     http://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz
                     http://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz
                     http://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz
                     http://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz
                     http://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz
                     http://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz
                     http://registry.npmjs.org/levn/-/levn-0.4.1.tgz
                     http://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz
                     http://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz
                     http://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz
                     http://registry.npmjs.org/ms/-/ms-2.1.3.tgz
                     http://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz
                     http://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz
                     http://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz
                     http://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz
                     http://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz
                     http://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz
                     http://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz
                     http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz
                     http://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz
                     http://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz
                     http://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz
                     http://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz
                     http://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz
                     http://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz
                     http://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz
                     http://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz
                     http://registry.npmjs.org/which/-/which-2.0.2.tgz
                     http://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz
                     http://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
SRC_URI="http://registry.npmjs.org/${PN}/-/${P}.tgz
         ${NODEJS_DEPS_SRC_URI}"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

DEPEND=""
RDEPEND="net-libs/nodejs[npm]"
BDEPEND="dev-nodejs/cjs-ledger"

src_unpack() {
	mkdir --parents ${S}/registry
	for f in ${DISTDIR}/*.tgz; do
		ln --symbolic --verbose ${f} ${S}/registry/$(basename $f)
	done
}

src_compile() {
	cjs-ledger ${S}/registry --exec npm --cache=${WORKDIR}/.npm-cache --cache=./cache --no-audit install ${PN}@${PV} || die "Error running npm"
}

src_install() {
	dodir /usr/lib64/node_modules/${PN}
	cp -R "${S}/node_modules/" "${D}/usr/lib64/node_modules/${PN}"
	cp "${S}/package-lock.json" "${D}/usr/lib64/node_modules/${PN}/package.json"

	for f in acorn eslint js-yaml node-which; do
		dosym ../lib64/node_modules/${PN}/node_modules/.bin/${f} /usr/bin/${f}
	done
}
